<?php

use Biz\model\ShopCategoryClassify;
use Biz\service\BrandPreFecture;

class RecommendBrandListAction extends ActionPlugin
{

    const USER_LEVEL = self::LEVEL_NOTHING;

    const DEFAULT_PAGESIZE = 8;

    public function main()
    {
        $show = 1;
        if(file_exists(BrandPreFecture::RECOMMEND_ONOFF_FILE)) {
            $on_off_json = file_get_contents(BrandPreFecture::RECOMMEND_ONOFF_FILE);
            $on_off_arr = json_decode($on_off_json, true);
            if(isset($on_off_arr['fine_goods_son']) && !(int) $on_off_arr['fine_goods_son']) {
                $show = 0;
            }
        }

        $list = [];
        if($show == 1) {
            $relate_id = (int) $this->getRequest()->get('category_id', '');
            $redis = new \Hhz\Redis\newCache(\hhz\constant\redis\redisKeys::KEY_B_CACHE_CATEGORY_CLASSIFY_);
            $cate_ids = $redis->getCache($relate_id);
            $tab_name = (string) ShopCategoryClassify::getInfo($relate_id)['classify_name'];
            $list = BrandPreFecture::recommendBrandsNotWiki($this->uid, $relate_id, $cate_ids, $tab_name, '好物子频道精选品牌');
        }
        $data['list'] = array_values($list);
        $this->setSuccess($data);
    }

}